package com.hgw.Demo05_PrototypePattern.example_DeepCloning;


import java.io.IOException;

/**
 * Data time:2021/12/12 17:18
 * StudentID:2019112118
 * Author:hgw
 * Description: 客户端测试类
 */
public class Client {

    public static void main(String[] args) throws CloneNotSupportedException {
        WeeklyLog log_previous,log_new = null;
        log_previous = new WeeklyLog();                 // 创建原型对象
        Attachment attachment = new Attachment();// 创建附件对象
        log_previous.setAttachment(attachment);       // 将附件添加到周报中

        try {
            log_new = log_previous.deepClone();
        } catch (Exception e) {
            System.out.println("克隆失败");
        }
        
        // 比较周报
        System.out.println("周报是否相同: " + (log_previous == log_new));
        // 比较附件
        System.out.println("附件是否相同：" + (log_previous.getAttachment() == log_new.getAttachment()));
    }

}

